<template>
  <div>
    <input
      ref="input"
      type="text"
      placeholder="请输入要搜索的关键字"
      v-if="flag"
    />
    <button @click="conceal" v-else>点击搜索</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      flag: false,
    }
  },

  methods: {
    conceal() {
      this.flag = !this.flag
      this.$nextTick(() => {
        this.$refs.input.focus()
      })
    },
  },
}
</script>

<style scoped></style>
